<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/


Auth::routes();

Route::get('/', 'TopicsController@index');
Route::get('topics/{category?}', 'TopicsController@index')->where('category', '[0-9]+')->name('topics');
Route::get('topics/{category}/{topics}', 'TopicsController@show')->where(['category' => '[0-9]+', 'id' => '[0-9]+'])->name('topics.show');
Route::get('get_topicjson/{topics}', 'TopicsController@getTopicjson')->where(['id' => '[0-9]+'])->name('topics.get_topicjson');
Route::get('replies/get', 'RepliesController@get')->name('replies.get');
#切换社区
Route::get('communities', 'CommunitiesController@index')->name('communities');
Route::get('selectcommunity/{id}', 'CommunitiesController@select')->name('communities.select');
Route::get('selectall', 'CommunitiesController@all')->name('communities.all');#选择查看所有社区的信息
Route::post('communities/get_by_county_id', 'CommunitiesController@getByCountyId')->name('communities.get_by_county_id');
#切换城市
Route::get('cities', 'CitiesController@index')->name('cities');

Route::middleware(['auth'])->group(function () {
    #ckeditor编辑器中上传图片
    Route::post('upload_ckeditor', 'UploadController@ckeditor')->name('upload.ckeditor');
    #常规上传
    Route::post('upload_index', 'UploadController@index')->name('upload');
    Route::post('upload_avatar', 'UploadController@avatar')->name('upload.avatar');

    #帖子
    Route::get('topics/form/{id?}', 'TopicsController@form')->name('topics.form');
    Route::post('topics/save', 'TopicsController@save')->name('topics.save');
    Route::post('topics/delete', 'TopicsController@delete')->name('topics.delete');
    Route::get('topics/set_top/{id}', 'TopicsController@setTop')->name('topics.set_top');
    #帖子回复
    Route::post('save_replies', 'RepliesController@save')->name('replies.save');
    Route::post('replies/delete', 'RepliesController@delete')->name('replies.delete');
    #用户信息
    Route::get('user/{id?}', 'UserController@index')->where('id', '[0-9]+')->name('user');
    Route::get('get_current_user_json', 'UserController@getCurrentUser')->where('id', '[0-9]+')->name('get_current_user_json');
    Route::get('user/edit', 'UserController@edit')->name('user.edit');
    Route::post('user/update', 'UserController@update')->name('user.update');

    #消息通知
    Route::get('notifications', 'NotificationsController@index')->name('notification');
});

